<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class lienhe_model extends CI_Model
{
	function __construct()
	{
		parent::__construct();
	}
	
	public function select()
	{
		$query = $this->db->query("SELECT * FROM lienhe");
		return $query->result();
	}
	
	public function insert($ten, $dienthoai, $email, $noidung)
	{
		$this->db->query("INSERT INTO lienhe VALUES (NULL, ?, ?, ?, ?, 1)", array($ten, $email, $dienthoai, $noidung));
		return $this->db->insert_id();
	}
	
	public function delete($id)
	{
		$this->db->query("DELETE FROM lienhe WHERE id = ?",array($id));
		$query = $this->db->query("SELECT id FROM lienhe WHERE id = ?",array($id));
		if($query->num_rows()>0) return FALSE; return TRUE;
	}
}